{% extends "base.html" %}

{% block title %}{{op.name}} (Operation){% endblock %}<a href='/editop?key={{op.key}}'>[Edit operation]</a>
{% block heading %}{{op.name}} (Operation){% endblock %}

{% block leftmenu %}
			{% if not op.locked %}
				<a href='/addpilot?id={{op.key.id}}'>Add pilot</a><br/>
			{% endif %}
			{% if can_edit %}
				<a href='/editop?id={{op.key.id}}'>Edit op</a><br/>
				<a href='/confirm?action=/deleteop&key={{op.key.id}}'>Delete op</a><br/>
				{% if op.locked %}
					<a href='/lockop?key={{op.key}}&locked=False'>Unlock op</a><br/>
				{% else %}
					<a href='/lockop?key={{op.key}}&locked=True'>Lock op</a><br/>
				{% endif %}
			{% endif %}
{% endblock %}

{% block content %}
		<table>
			<tr class="standard">
				<td>Op name:</td>
				<td>{{op.name}}</td>
			</tr>
			<tr class="standard">
				<td>Op type:</td>
				<td>{{op.op_type}}</td>
			</tr>
			<tr class="standard">
				<td>Date:</td>
				<td>{{op.op_date|date:"j F Y"}}</td>
			</tr>			
			<tr class="standard">
				<td>Time:</td>
				<td>{{op.op_time|time}}</td>
			</tr>	
			<tr class="standard">
				<td>System:</td>
				<td>
				{% if op.system %}
					{% ifequal op.system 'Unknown' %}
						Unknown
					{% else %}
						<a href='http://evemaps.dotlan.net/system/{{op.system}}' target="_blank">{{op.system}}</a>
					{% endifequal %}
				{% else %}
					Unknown
				{% endif %}
				</td>
			</tr>	
			<tr class="standard">
				<td>Site type:</td>
				<td><a href='/viewsite?name={{op.site_type}}'>{{op.site_type}}</a></td>
			</tr>	
			<tr class="standard">
				<td>Site count:</td>
				<td>{{op.site_count}}</td>
			</tr>	
			<tr class="standard">
				<td>Corp:</td>
				<td>{{op.corp_name}}</td>
			</tr>			
			<tr class="standard">
				<td>Locked:</td>
				<td>{{op.locked}}</td>
			</tr>			
			<tr class="standard">
				<td>Pilots:</td>
				<td>{{op.pilots|length}}</td>
				<td>Role</td>
				{% if not op.locked %}
					<td>&nbsp;</td>
				{% endif %}
				{% for assist in assist_types %}
					<td>{{assist.name}}</td>
				{% endfor %}
			</tr>
			{% for pilot in pilot_info %}
				<tr class="standard">
					<td align='right'>&nbsp;
							{% if is_fc %}
								&nbsp;&nbsp;&nbsp;<a href="/removepilot?id={{op.key.id}}&pilot={{pilot.name}}" alt='Remove'>x</a>
							{% endif %}
					</td>
					<td>
						{{ pilot.name }}
						{% ifequal pilot.name op.fc %}
							(FC)
						{% endifequal %}
					</td>
					<td>{{ pilot.role }}</td>
					{% if not op.locked %}
						<td><a href="/setrole?id={{op.key.id}}&pilot={{pilot.name}}">[Set role]</a></td>
					{% endif %}
					{% for assist in pilot.assists %}
						<td>
							{{assist.assignees}}
							{{assist.offered}}
							{% if not op.locked %}
								{% if pilot.is_current %}
									<a href='/addassist?kind={{assist.name}}&id={{op.key.id}}&pilot={{pilot.name}}&value=1'>+</a>
									<a href='/addassist?kind={{assist.name}}&id={{op.key.id}}&pilot={{pilot.name}}&value=-1'>-</a>
									{% ifnotequal 0 assist.claimed %}
										<a href='/claimassist?kind={{assist.name}}&id={{op.key.id}}&pilot={{pilot.name}}&clear=True'>x</a>
									{% endifnotequal %}
								{% else %}
									{% ifnotequal 0 assist.offered %}
									<a href='/claimassist?kind={{assist.name}}&id={{op.key.id}}&pilot={{pilot.name}}'>claim</a>
									{% endifnotequal %}
								{% endif %}
							{% endif %}
						</td>
					{% endfor %}
				</tr>
			{% endfor %}
		</table>
{% endblock %}
